#include <iostream>
#include <cmath>
#include "matrix.h"
#include "matrix_util.h"
#include "mesh.h"
#include "primitive.h"

typedef typename MeshPrimitive<float>::PointType     PointType  ;
typedef typename MeshPrimitive<float>::VectorType    VectorType ;
typedef typename MeshPrimitive<float>::FaceType      FaceType   ;
typedef typename MeshPrimitive<float>::VertexType    VertexType   ;
typedef Mesh <MeshPrimitive<float> >                 MeshType ;

int main(int argc, char ** argv)
{
	Line <float> l1 (PointType (0,0,0), VectorType (1,1,0));
        Line <float> l2 (PointType (1,0,0), VectorType (-1,1,0));

	std::cout<<l1.intersect(l2);
	
	VectorType v1 (1, 0, 0);
	VectorType v2 (1, 0, 1);

	v1 += v2 ;
	std::cout<< v1 <<std::endl;

	std::cout<< v2 + v1 <<std::endl;
	std::cout<< (v2 + v1) / 4.0f <<std::endl;

	//VectorType v5 (0, 0, 0), v6 (0, 1, 0), v7 (1, 1, 0), v8(1, 0, 0);
	VectorType v5 (1, 0, 0), v6 (0, 1, 0), v7 (0, 1, 1), v8(1, 0, 1);
	//VectorType v5 (3, 2, 0), v6 (3, 3, 0), v7 (4, 3, 0), v8(4, 2, 0);

	std::vector<PointType> vset ;
	vset.push_back(v5); vset.push_back(v6); vset.push_back(v7); vset.push_back(v8);
	Polygon<float> polygon(vset) ;
 
	std::cout<<"AREA "<<polygon.get_area()<<std::endl;
	/*
        MeshType mesh ;
        try
        {

                std::ifstream ifs (argv[1]);
                ifs >> (mesh) ;
		
		for (MeshType::VertexIterator iter = mesh.vertices.begin(); iter != mesh.vertices.end(); ++iter)
		{
			VertexType * v = iter->second ;
			std::cout<<v->m_idx<<" : "; 
			for (VertexType::VVIter vv_iter = v->vv_begin(); vv_iter != v->vv_end(); ++vv_iter)
			{
				std::cout<<(*vv_iter)->m_idx<<' ';
			}
			std::cout<<std::endl;
		}
        }
        catch (const char * msg)
        {
                std::cerr<<msg<<std::endl;      
        }
	*/
}
